﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Text.RegularExpressions;

namespace LightPersistTests
{
	[TestClass]
	public class TestTripleGenerator
	{
		[TestMethod]
		public void Should_find_test_classes()
		{
			Assert.AreEqual("Class_1" ,
											sut(@"

using...
{

	[TestClass]
	public void Class_1 : TripleTestsBase
	{

").FirstOrDefault());

			CollectionAssert.AreEqual(new[] { "Class_1", "Class_2", },
					sut(@"

using...
{

	[TestClass]
	public void Class_1 : TripleTestsBase
	{using...
{

	[TestClass]
	public void Class_2 
					: 
					TripleTestsBase
	{

").ToArray());
		}

		static IEnumerable<string> sut(string input)
		{
			foreach (Match match in Regex.Matches(input, @"(?i)\[TestClass\]\s*public void (?'name'[a-z01-9_]+)\s*:\s*TripleTestsBase"))
			{
				yield return match.Groups["name"].Value;
			}
		}
	}
}
